#include "WorkbenchPy.h"
#include "Workbench.h"


std::string WorkbenchPy::representation(void) const
{
	return std::string("<Workbench object>");
}

PyObject* WorkbenchPy::Initialize(PyObject* args)
{
	if (!PyArg_ParseTuple(args, ""))
		return nullptr;

	PY_TRY{
		getWorkbenchPtr()->Initialize();
	Py_Return;
	}PY_CATCH;
}

PyObject* WorkbenchPy::GetClassName(PyObject* args)
{
	if (!PyArg_ParseTuple(args, ""))
		return nullptr;

	PY_TRY{
		Py::String menuText(getWorkbenchPtr()->GetClassName());
		return Py::new_reference_to(menuText);
	}PY_CATCH;
}

PyObject* WorkbenchPy::getCustomAttributes(const char* attr) const
{
	/*if (this->ob_type->tp_dict == nullptr) {
		if (PyType_Ready(this->ob_type) < 0)
			return 0;
	}
	PyObject* item = PyDict_GetItemString(this->ob_type->tp_dict, attr);
	return item;*/
	return nullptr;
}

int WorkbenchPy::setCustomAttributes(const char* attr, PyObject* obj)
{
	if (this->ob_type->tp_dict == nullptr) {
		if (PyType_Ready(this->ob_type) < 0)
			return 0;
	}
	PyObject* item = PyDict_GetItemString(this->ob_type->tp_dict, attr);
	if (item)
		return 0;
	int ret=PyDict_SetItemString(this->ob_type->tp_dict, attr, obj);
	return ret;
}
